C#########################################################
C This file is part of OpenAD released under the LGPL.   #
C The full COPYRIGHT notice can be found in the top      #
C level directory of the OpenAD distribution             #
C#########################################################
C
C$OPENAD XXX File_start [head.f]
      SUBROUTINE head(NX, NY, X, FVEC, R)
          use OAD_tape
          use OAD_rev
          use OAD_cp

C original arguments get inserted before version
C         ! and declared here together with all local variables
C         ! generated by xaifBooster

      use OAD_active
      use w2f__types
      use oad_intrinsics
      use oad_intrinsics
      use oad_intrinsics
      IMPLICIT NONE
C
C     **** Global Variables & Derived Type Definitions ****
C
      INTEGER(w2f__i8) OpenAD_Symbol_0
      INTEGER(w2f__i8) OpenAD_Symbol_1
      INTEGER(w2f__i8) OpenAD_Symbol_10
      INTEGER(w2f__i8) OpenAD_Symbol_11
      INTEGER(w2f__i8) OpenAD_Symbol_12
      INTEGER(w2f__i8) OpenAD_Symbol_13
      INTEGER(w2f__i8) OpenAD_Symbol_14
      INTEGER(w2f__i8) OpenAD_Symbol_15
      INTEGER(w2f__i8) OpenAD_Symbol_16
      INTEGER(w2f__i8) OpenAD_Symbol_17
      INTEGER(w2f__i8) OpenAD_Symbol_18
      INTEGER(w2f__i8) OpenAD_Symbol_19
      INTEGER(w2f__i8) OpenAD_Symbol_2
      INTEGER(w2f__i8) OpenAD_Symbol_20
      INTEGER(w2f__i8) OpenAD_Symbol_21
      INTEGER(w2f__i8) OpenAD_Symbol_22
      INTEGER(w2f__i8) OpenAD_Symbol_23
      INTEGER(w2f__i8) OpenAD_Symbol_24
      INTEGER(w2f__i8) OpenAD_Symbol_25
      INTEGER(w2f__i8) OpenAD_Symbol_26
      INTEGER(w2f__i8) OpenAD_Symbol_27
      INTEGER(w2f__i8) OpenAD_Symbol_28
      INTEGER(w2f__i8) OpenAD_Symbol_29
      INTEGER(w2f__i8) OpenAD_Symbol_3
      INTEGER(w2f__i8) OpenAD_Symbol_30
      INTEGER(w2f__i8) OpenAD_Symbol_31
      INTEGER(w2f__i8) OpenAD_Symbol_32
      INTEGER(w2f__i8) OpenAD_Symbol_33
      INTEGER(w2f__i8) OpenAD_Symbol_34
      INTEGER(w2f__i8) OpenAD_Symbol_35
      INTEGER(w2f__i8) OpenAD_Symbol_36
      INTEGER(w2f__i8) OpenAD_Symbol_37
      INTEGER(w2f__i8) OpenAD_Symbol_38
      INTEGER(w2f__i8) OpenAD_Symbol_39
      INTEGER(w2f__i8) OpenAD_Symbol_4
      INTEGER(w2f__i8) OpenAD_Symbol_40
      INTEGER(w2f__i8) OpenAD_Symbol_41
      INTEGER(w2f__i8) OpenAD_Symbol_42
      INTEGER(w2f__i8) OpenAD_Symbol_43
      INTEGER(w2f__i8) OpenAD_Symbol_44
      INTEGER(w2f__i8) OpenAD_Symbol_45
      INTEGER(w2f__i8) OpenAD_Symbol_46
      INTEGER(w2f__i8) OpenAD_Symbol_47
      INTEGER(w2f__i8) OpenAD_Symbol_48
      INTEGER(w2f__i8) OpenAD_Symbol_49
      INTEGER(w2f__i8) OpenAD_Symbol_5
      INTEGER(w2f__i8) OpenAD_Symbol_50
      INTEGER(w2f__i8) OpenAD_Symbol_51
      INTEGER(w2f__i8) OpenAD_Symbol_52
      INTEGER(w2f__i8) OpenAD_Symbol_53
      INTEGER(w2f__i8) OpenAD_Symbol_54
      INTEGER(w2f__i8) OpenAD_Symbol_55
      INTEGER(w2f__i8) OpenAD_Symbol_56
      INTEGER(w2f__i8) OpenAD_Symbol_57
      INTEGER(w2f__i8) OpenAD_Symbol_58
      INTEGER(w2f__i8) OpenAD_Symbol_59
      INTEGER(w2f__i8) OpenAD_Symbol_6
      INTEGER(w2f__i8) OpenAD_Symbol_60
      INTEGER(w2f__i8) OpenAD_Symbol_61
      INTEGER(w2f__i8) OpenAD_Symbol_62
      INTEGER(w2f__i8) OpenAD_Symbol_63
      INTEGER(w2f__i8) OpenAD_Symbol_64
      INTEGER(w2f__i8) OpenAD_Symbol_65
      INTEGER(w2f__i8) OpenAD_Symbol_66
      INTEGER(w2f__i8) OpenAD_Symbol_67
      INTEGER(w2f__i8) OpenAD_Symbol_68
      INTEGER(w2f__i8) OpenAD_Symbol_69
      INTEGER(w2f__i8) OpenAD_Symbol_7
      INTEGER(w2f__i8) OpenAD_Symbol_70
      INTEGER(w2f__i8) OpenAD_Symbol_71
      INTEGER(w2f__i8) OpenAD_Symbol_72
      INTEGER(w2f__i8) OpenAD_Symbol_73
      INTEGER(w2f__i8) OpenAD_Symbol_74
      INTEGER(w2f__i8) OpenAD_Symbol_75
      INTEGER(w2f__i8) OpenAD_Symbol_76
      INTEGER(w2f__i8) OpenAD_Symbol_77
      INTEGER(w2f__i8) OpenAD_Symbol_78
      INTEGER(w2f__i8) OpenAD_Symbol_79
      INTEGER(w2f__i8) OpenAD_Symbol_8
      INTEGER(w2f__i8) OpenAD_Symbol_80
      INTEGER(w2f__i8) OpenAD_Symbol_81
      INTEGER(w2f__i8) OpenAD_Symbol_82
      INTEGER(w2f__i8) OpenAD_Symbol_83
      INTEGER(w2f__i8) OpenAD_Symbol_9
C
C     **** Parameters and Result ****
C
      INTEGER(w2f__i4) NX
      INTEGER(w2f__i4) NY
      type(active) :: X(1:INT((NX*NY)))
      type(active) :: FVEC(1:INT((NX*NY)))
      REAL(w2f__8) R
C
C     **** Local Variables and Functions ****
C
      type(active) :: DPDX
      type(active) :: DPDY
      REAL(w2f__8) FOUR
      PARAMETER ( FOUR = 4.0D00)
      REAL(w2f__8) HX
      REAL(w2f__8) HX2
      REAL(w2f__8) HY
      REAL(w2f__8) HY2
      INTEGER(w2f__i4) I
      INTEGER(w2f__i4) J
      INTEGER(w2f__i4) K
      INTEGER(w2f__i4) N
      REAL(w2f__8) NXP1
      REAL(w2f__8) NYP1
      REAL(w2f__8) ONE
      PARAMETER ( ONE = 1.0D00)
      type(active) :: P
      type(active) :: PB
      type(active) :: PBB
      type(active) :: PBL
      type(active) :: PBLAP
      type(active) :: PBR
      type(active) :: PL
      type(active) :: PLAP
      type(active) :: PLL
      type(active) :: PLLAP
      type(active) :: PR
      type(active) :: PRLAP
      type(active) :: PRR
      type(active) :: PT
      type(active) :: PTL
      type(active) :: PTLAP
      type(active) :: PTR
      type(active) :: PTT
      REAL(w2f__8) THREE
      PARAMETER ( THREE = 3.0D00)
      REAL(w2f__8) TWO
      PARAMETER ( TWO = 2.0D00)
      REAL(w2f__8) ZERO
      PARAMETER ( ZERO = 0.0D00)
      INTEGER(w2f__i4) OpenAD_Symbol_100
      INTEGER(w2f__i4) OpenAD_Symbol_101
      INTEGER(w2f__i4) OpenAD_Symbol_102
      INTEGER(w2f__i4) OpenAD_Symbol_103
      INTEGER(w2f__i4) OpenAD_Symbol_104
      INTEGER(w2f__i4) OpenAD_Symbol_105
      REAL(w2f__8) OpenAD_Symbol_106
      REAL(w2f__8) OpenAD_Symbol_107
      REAL(w2f__8) OpenAD_Symbol_108
      REAL(w2f__8) OpenAD_Symbol_109
      REAL(w2f__8) OpenAD_Symbol_110
      REAL(w2f__8) OpenAD_Symbol_111
      REAL(w2f__8) OpenAD_Symbol_112
      REAL(w2f__8) OpenAD_Symbol_113
      REAL(w2f__8) OpenAD_Symbol_114
      REAL(w2f__8) OpenAD_Symbol_115
      REAL(w2f__8) OpenAD_Symbol_116
      REAL(w2f__8) OpenAD_Symbol_117
      INTEGER(w2f__i4) OpenAD_Symbol_118
      INTEGER(w2f__i4) OpenAD_Symbol_119
      INTEGER(w2f__i4) OpenAD_Symbol_120
      INTEGER(w2f__i4) OpenAD_Symbol_121
      INTEGER(w2f__i4) OpenAD_Symbol_122
      INTEGER(w2f__i4) OpenAD_Symbol_123
      INTEGER(w2f__i4) OpenAD_Symbol_124
      INTEGER(w2f__i4) OpenAD_Symbol_125
      INTEGER(w2f__i4) OpenAD_Symbol_126
      INTEGER(w2f__i4) OpenAD_Symbol_127
      INTEGER(w2f__i4) OpenAD_Symbol_128
      INTEGER(w2f__i4) OpenAD_Symbol_129
      INTEGER(w2f__i4) OpenAD_Symbol_130
      INTEGER(w2f__i4) OpenAD_Symbol_131
      INTEGER(w2f__i4) OpenAD_Symbol_132
      INTEGER(w2f__i4) OpenAD_Symbol_133
      INTEGER(w2f__i4) OpenAD_Symbol_84
      INTEGER(w2f__i4) OpenAD_Symbol_85
      INTEGER(w2f__i4) OpenAD_Symbol_86
      INTEGER(w2f__i4) OpenAD_Symbol_87
      INTEGER(w2f__i4) OpenAD_Symbol_88
      INTEGER(w2f__i4) OpenAD_Symbol_89
      INTEGER(w2f__i4) OpenAD_Symbol_90
      INTEGER(w2f__i4) OpenAD_Symbol_91
      INTEGER(w2f__i4) OpenAD_Symbol_92
      INTEGER(w2f__i4) OpenAD_Symbol_93
      INTEGER(w2f__i4) OpenAD_Symbol_94
      INTEGER(w2f__i4) OpenAD_Symbol_95
      INTEGER(w2f__i4) OpenAD_Symbol_96
      INTEGER(w2f__i4) OpenAD_Symbol_97
      INTEGER(w2f__i4) OpenAD_Symbol_98
      INTEGER(w2f__i4) OpenAD_Symbol_99
      REAL(w2f__8) OpenAD_acc_0
      REAL(w2f__8) OpenAD_acc_1
      REAL(w2f__8) OpenAD_acc_10
      REAL(w2f__8) OpenAD_acc_11
      REAL(w2f__8) OpenAD_acc_12
      REAL(w2f__8) OpenAD_acc_13
      REAL(w2f__8) OpenAD_acc_14
      REAL(w2f__8) OpenAD_acc_15
      REAL(w2f__8) OpenAD_acc_16
      REAL(w2f__8) OpenAD_acc_17
      REAL(w2f__8) OpenAD_acc_18
      REAL(w2f__8) OpenAD_acc_19
      REAL(w2f__8) OpenAD_acc_2
      REAL(w2f__8) OpenAD_acc_20
      REAL(w2f__8) OpenAD_acc_3
      REAL(w2f__8) OpenAD_acc_4
      REAL(w2f__8) OpenAD_acc_5
      REAL(w2f__8) OpenAD_acc_6
      REAL(w2f__8) OpenAD_acc_7
      REAL(w2f__8) OpenAD_acc_8
      REAL(w2f__8) OpenAD_acc_9
      REAL(w2f__8) OpenAD_aux_0
      REAL(w2f__8) OpenAD_aux_1
      REAL(w2f__8) OpenAD_aux_10
      REAL(w2f__8) OpenAD_aux_11
      REAL(w2f__8) OpenAD_aux_12
      REAL(w2f__8) OpenAD_aux_13
      REAL(w2f__8) OpenAD_aux_14
      REAL(w2f__8) OpenAD_aux_15
      REAL(w2f__8) OpenAD_aux_16
      REAL(w2f__8) OpenAD_aux_17
      REAL(w2f__8) OpenAD_aux_18
      REAL(w2f__8) OpenAD_aux_19
      REAL(w2f__8) OpenAD_aux_2
      REAL(w2f__8) OpenAD_aux_20
      REAL(w2f__8) OpenAD_aux_21
      REAL(w2f__8) OpenAD_aux_22
      REAL(w2f__8) OpenAD_aux_3
      REAL(w2f__8) OpenAD_aux_4
      REAL(w2f__8) OpenAD_aux_5
      REAL(w2f__8) OpenAD_aux_6
      REAL(w2f__8) OpenAD_aux_7
      REAL(w2f__8) OpenAD_aux_8
      REAL(w2f__8) OpenAD_aux_9
      REAL(w2f__8) OpenAD_lin_0
      REAL(w2f__8) OpenAD_lin_1
      REAL(w2f__8) OpenAD_lin_10
      REAL(w2f__8) OpenAD_lin_11
      REAL(w2f__8) OpenAD_lin_12
      REAL(w2f__8) OpenAD_lin_13
      REAL(w2f__8) OpenAD_lin_14
      REAL(w2f__8) OpenAD_lin_15
      REAL(w2f__8) OpenAD_lin_16
      REAL(w2f__8) OpenAD_lin_17
      REAL(w2f__8) OpenAD_lin_18
      REAL(w2f__8) OpenAD_lin_19
      REAL(w2f__8) OpenAD_lin_2
      REAL(w2f__8) OpenAD_lin_20
      REAL(w2f__8) OpenAD_lin_3
      REAL(w2f__8) OpenAD_lin_4
      REAL(w2f__8) OpenAD_lin_5
      REAL(w2f__8) OpenAD_lin_6
      REAL(w2f__8) OpenAD_lin_7
      REAL(w2f__8) OpenAD_lin_8
      REAL(w2f__8) OpenAD_lin_9
      type(active) :: OpenAD_prp_0
      type(active) :: OpenAD_prp_1
      type(active) :: OpenAD_prp_10
      type(active) :: OpenAD_prp_11
      type(active) :: OpenAD_prp_2
      type(active) :: OpenAD_prp_3
      type(active) :: OpenAD_prp_4
      type(active) :: OpenAD_prp_5
      type(active) :: OpenAD_prp_6
      type(active) :: OpenAD_prp_7
      type(active) :: OpenAD_prp_8
      type(active) :: OpenAD_prp_9


C checkpointing stacks and offsets
          integer :: cp_loop_variable_1,cp_loop_variable_2,cp_loop_varia
     +ble_3,cp_loop_variable_4,cp_loop_variable_5,cp_loop_variable_6

C floats 'F'
          double precision, dimension(:), allocatable, save :: theArgFSt
     +ack
          integer, save :: theArgFStackoffset=0, theArgFStackSize=0
C integers 'I'
          integer, dimension(:), allocatable, save :: theArgIStack
          integer, save :: theArgIStackoffset=0, theArgIStackSize=0
C booleans 'B'
          logical, dimension(:), allocatable, save :: theArgBStack
          integer, save :: theArgBStackoffset=0, theArgBStackSize=0
C strings 'S'
          character*(80), dimension(:), allocatable, save :: theArgSStac
     +k
          integer, save :: theArgSStackoffset=0, theArgSStackSize=0

          type(modeType) :: our_orig_mode

C external C function used in inlined code
          integer iaddr
          external iaddr
C
C     **** Top Level Pragmas ****
C
C$OPENAD INDEPENDENT(X)
C$OPENAD DEPENDENT(FVEC)
C
C     **** Statements ****
C

          if (our_rev_mode%arg_store) then
C store arguments
          end if
          if (our_rev_mode%arg_restore) then
C restore arguments
          end if
          if (our_rev_mode%plain) then
            our_orig_mode=our_rev_mode
            our_rev_mode%arg_store=.FALSE.
C original function
C$OPENAD XXX Template ad_template.f
      N = (NX * NY)
      NXP1 = (NX + 1)
      NYP1 = (NY + 1)
      HX = (1.0D00 / NXP1)
      HY = (1.0D00 / NYP1)
      HY2 = (HY * HY)
      HX2 = (HX * HX)
      DO I = 1, NY, 1
        DO J = 1, NX, 1
          K = (J + NX *(I +(-1)))
          IF((I .eq. 1) .OR.(J .eq. 1)) THEN
            PBL%v = 0.0D00
          ELSE
            PBL%v = X(K-NX+(-1))%v
          ENDIF
          IF (I.eq.1) THEN
            PB%v = 0.0D00
            PBB%v = X(K)%v
          ELSE
            IF (I.eq.2) THEN
              PB%v = X(K-NX)%v
              PBB%v = 0.0D00
            ELSE
              PB%v = X(K-NX)%v
              PBB%v = X(K-NX*2)%v
            ENDIF
          ENDIF
          IF ((NX.eq.J).OR.(I.eq.1)) THEN
            PBR%v = 0.0D00
          ELSE
            PBR%v = X(K-NX+1)%v
          ENDIF
          IF (J.eq.1) THEN
            PL%v = 0.0D00
            PLL%v = X(K)%v
          ELSE
            IF (J.eq.2) THEN
              PL%v = X(K+(-1))%v
              PLL%v = 0.0D00
            ELSE
              PL%v = X(K+(-1))%v
              PLL%v = X(K+(-2))%v
            ENDIF
          ENDIF
          P%v = X(K)%v
          IF (J.eq.(NX+(-1))) THEN
            PR%v = X(K+1)%v
            PRR%v = 0.0D00
          ELSE
            IF (NX.eq.J) THEN
              PR%v = 0.0D00
              PRR%v = X(K)%v
            ELSE
              PR%v = X(K+1)%v
              PRR%v = X(K+2)%v
            ENDIF
          ENDIF
          IF ((NY.eq.I).OR.(J.eq.1)) THEN
            PTL%v = 0.0D00
          ELSE
            PTL%v = X(NX+K+(-1))%v
          ENDIF
          IF (I.eq.(NY+(-1))) THEN
            PT%v = X(NX+K)%v
            PTT%v = 0.0D00
          ELSE
            IF (NY.eq.I) THEN
              PT%v = 0.0D00
              PTT%v = X(K)%v
            ELSE
              PT%v = X(NX+K)%v
              PTT%v = X(K+NX*2)%v
            ENDIF
          ENDIF
          IF ((NX.eq.J).OR.(NY.eq.I)) THEN
            PTR%v = 0.0D00
          ELSE
            PTR%v = X(NX+K+1)%v
          ENDIF
          DPDY%v = ((PT%v-PB%v)/(HY*2.0D00))
          DPDX%v = ((PR%v-PL%v)/(HX*2.0D00))
          PBLAP%v = (((PBB%v+P%v-PB%v*2.0D00)/HY2)+((PBL%v+PBR%v-PB%v*2.
     +0D00)/HX2))
          PLLAP%v = (((PBL%v+PTL%v-PL%v*2.0D00)/HY2)+((PLL%v+P%v-PL%v*2.
     +0D00)/HX2))
          PLAP%v = (((PB%v+PT%v-P%v*2.0D00)/HY2)+((PL%v+PR%v-P%v*2.0D00)
     +/HX2))
          PRLAP%v = (((P%v+PRR%v-PR%v*2.0D00)/HX2)+((PBR%v+PTR%v-PR%v*2.
     +0D00)/HY2))
          PTLAP%v = (((P%v+PTT%v-PT%v*2.0D00)/HY2)+((PTL%v+PTR%v-PT%v*2.
     +0D00)/HX2))
          FVEC(INT(K))%v = (((PBLAP%v+PTLAP%v-PLAP%v*2.0D00)/HY2)+((PLLA
     +P%v+PRLAP%v-PLAP%v*2.0D00)/HX2)-R*(((DPDY%v*(PRLAP%v-PLLAP%v))/(HX
     +*2.0D00))-((DPDX%v*(PTLAP%v-PBLAP%v))/(HY*2.0D00))))
        END DO
      END DO

C original function end
            our_rev_mode=our_orig_mode
          end if
          if (our_rev_mode%tape) then
C            print*, " tape       ", our_rev_mode
            our_rev_mode%arg_store=.TRUE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.TRUE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.FALSE.
C taping
C$OPENAD XXX Template ad_template.f
      N = (NX*NY)
      NXP1 = (NX+1)
      NYP1 = (NY+1)
      HX = (1.0D00/NXP1)
      HY = (1.0D00/NYP1)
      HY2 = (HY*HY)
      HX2 = (HX*HX)
      OpenAD_Symbol_16 = 0_w2f__i8
      DO I = 1,NY,1
        OpenAD_Symbol_17 = 0_w2f__i8
        DO J = 1,NX,1
          K = (J+NX*(I+(-1)))
          IF ((I.eq.1).OR.(J.eq.1)) THEN
            PBL%v = 0.0D00
            OpenAD_Symbol_18 = 1_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_18
            integer_tape_pointer = integer_tape_pointer+1
          ELSE
            PBL%v = X(K-NX+(-1))%v
            OpenAD_Symbol_99 = (K-NX+(-1))
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_99
            integer_tape_pointer = integer_tape_pointer+1
            OpenAD_Symbol_19 = 0_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_19
            integer_tape_pointer = integer_tape_pointer+1
          ENDIF
          IF (I.eq.1) THEN
            PB%v = 0.0D00
            PBB%v = X(K)%v
            integer_tape(integer_tape_pointer) = K
            integer_tape_pointer = integer_tape_pointer+1
            OpenAD_Symbol_22 = 1_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_22
            integer_tape_pointer = integer_tape_pointer+1
          ELSE
            IF (I.eq.2) THEN
              PB%v = X(K-NX)%v
              PBB%v = 0.0D00
              OpenAD_Symbol_96 = (K-NX)
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_96
              integer_tape_pointer = integer_tape_pointer+1
              OpenAD_Symbol_20 = 1_w2f__i8
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_20
              integer_tape_pointer = integer_tape_pointer+1
            ELSE
              PB%v = X(K-NX)%v
              PBB%v = X(K-NX*2)%v
              OpenAD_Symbol_97 = (K-NX)
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_97
              integer_tape_pointer = integer_tape_pointer+1
              OpenAD_Symbol_98 = (K-NX*2)
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_98
              integer_tape_pointer = integer_tape_pointer+1
              OpenAD_Symbol_21 = 0_w2f__i8
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_21
              integer_tape_pointer = integer_tape_pointer+1
            ENDIF
            OpenAD_Symbol_23 = 0_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_23
            integer_tape_pointer = integer_tape_pointer+1
          ENDIF
          IF ((NX.eq.J).OR.(I.eq.1)) THEN
            PBR%v = 0.0D00
            OpenAD_Symbol_24 = 1_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_24
            integer_tape_pointer = integer_tape_pointer+1
          ELSE
            PBR%v = X(K-NX+1)%v
            OpenAD_Symbol_95 = (K-NX+1)
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_95
            integer_tape_pointer = integer_tape_pointer+1
            OpenAD_Symbol_25 = 0_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_25
            integer_tape_pointer = integer_tape_pointer+1
          ENDIF
          IF (J.eq.1) THEN
            PL%v = 0.0D00
            PLL%v = X(K)%v
            integer_tape(integer_tape_pointer) = K
            integer_tape_pointer = integer_tape_pointer+1
            OpenAD_Symbol_28 = 1_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_28
            integer_tape_pointer = integer_tape_pointer+1
          ELSE
            IF (J.eq.2) THEN
              PL%v = X(K+(-1))%v
              PLL%v = 0.0D00
              OpenAD_Symbol_92 = (K+(-1))
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_92
              integer_tape_pointer = integer_tape_pointer+1
              OpenAD_Symbol_26 = 1_w2f__i8
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_26
              integer_tape_pointer = integer_tape_pointer+1
            ELSE
              PL%v = X(K+(-1))%v
              PLL%v = X(K+(-2))%v
              OpenAD_Symbol_93 = (K+(-1))
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_93
              integer_tape_pointer = integer_tape_pointer+1
              OpenAD_Symbol_94 = (K+(-2))
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_94
              integer_tape_pointer = integer_tape_pointer+1
              OpenAD_Symbol_27 = 0_w2f__i8
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_27
              integer_tape_pointer = integer_tape_pointer+1
            ENDIF
            OpenAD_Symbol_29 = 0_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_29
            integer_tape_pointer = integer_tape_pointer+1
          ENDIF
          P%v = X(K)%v
          integer_tape(integer_tape_pointer) = K
          integer_tape_pointer = integer_tape_pointer+1
          IF (J.eq.(NX+(-1))) THEN
            PR%v = X(K+1)%v
            PRR%v = 0.0D00
            OpenAD_Symbol_84 = (K+1)
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_84
            integer_tape_pointer = integer_tape_pointer+1
            OpenAD_Symbol_32 = 1_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_32
            integer_tape_pointer = integer_tape_pointer+1
          ELSE
            IF (NX.eq.J) THEN
              PR%v = 0.0D00
              PRR%v = X(K)%v
              integer_tape(integer_tape_pointer) = K
              integer_tape_pointer = integer_tape_pointer+1
              OpenAD_Symbol_30 = 1_w2f__i8
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_30
              integer_tape_pointer = integer_tape_pointer+1
            ELSE
              PR%v = X(K+1)%v
              PRR%v = X(K+2)%v
              OpenAD_Symbol_90 = (K+1)
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_90
              integer_tape_pointer = integer_tape_pointer+1
              OpenAD_Symbol_91 = (K+2)
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_91
              integer_tape_pointer = integer_tape_pointer+1
              OpenAD_Symbol_31 = 0_w2f__i8
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_31
              integer_tape_pointer = integer_tape_pointer+1
            ENDIF
            OpenAD_Symbol_33 = 0_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_33
            integer_tape_pointer = integer_tape_pointer+1
          ENDIF
          IF ((NY.eq.I).OR.(J.eq.1)) THEN
            PTL%v = 0.0D00
            OpenAD_Symbol_34 = 1_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_34
            integer_tape_pointer = integer_tape_pointer+1
          ELSE
            PTL%v = X(NX+K+(-1))%v
            OpenAD_Symbol_89 = (NX+K+(-1))
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_89
            integer_tape_pointer = integer_tape_pointer+1
            OpenAD_Symbol_35 = 0_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_35
            integer_tape_pointer = integer_tape_pointer+1
          ENDIF
          IF (I.eq.(NY+(-1))) THEN
            PT%v = X(NX+K)%v
            PTT%v = 0.0D00
            OpenAD_Symbol_85 = (NX+K)
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_85
            integer_tape_pointer = integer_tape_pointer+1
            OpenAD_Symbol_38 = 1_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_38
            integer_tape_pointer = integer_tape_pointer+1
          ELSE
            IF (NY.eq.I) THEN
              PT%v = 0.0D00
              PTT%v = X(K)%v
              integer_tape(integer_tape_pointer) = K
              integer_tape_pointer = integer_tape_pointer+1
              OpenAD_Symbol_36 = 1_w2f__i8
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_36
              integer_tape_pointer = integer_tape_pointer+1
            ELSE
              PT%v = X(NX+K)%v
              PTT%v = X(K+NX*2)%v
              OpenAD_Symbol_87 = (NX+K)
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_87
              integer_tape_pointer = integer_tape_pointer+1
              OpenAD_Symbol_88 = (K+NX*2)
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_88
              integer_tape_pointer = integer_tape_pointer+1
              OpenAD_Symbol_37 = 0_w2f__i8
              integer_tape(integer_tape_pointer) = OpenAD_Symbol_37
              integer_tape_pointer = integer_tape_pointer+1
            ENDIF
            OpenAD_Symbol_39 = 0_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_39
            integer_tape_pointer = integer_tape_pointer+1
          ENDIF
          IF ((NX.eq.J).OR.(NY.eq.I)) THEN
            PTR%v = 0.0D00
            OpenAD_Symbol_40 = 1_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_40
            integer_tape_pointer = integer_tape_pointer+1
          ELSE
            PTR%v = X(NX+K+1)%v
            OpenAD_Symbol_86 = (NX+K+1)
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_86
            integer_tape_pointer = integer_tape_pointer+1
            OpenAD_Symbol_41 = 0_w2f__i8
            integer_tape(integer_tape_pointer) = OpenAD_Symbol_41
            integer_tape_pointer = integer_tape_pointer+1
          ENDIF
          OpenAD_aux_0 = (PT%v-PB%v)
          OpenAD_aux_1 = (HY*2.0D00)
          OpenAD_lin_0 = (INT(1_w2f__i8)/OpenAD_aux_1)
          DPDY%v = (OpenAD_aux_0/OpenAD_aux_1)
          OpenAD_aux_2 = (PR%v-PL%v)
          OpenAD_aux_3 = (HX*2.0D00)
          OpenAD_lin_1 = (INT(1_w2f__i8)/OpenAD_aux_3)
          DPDX%v = (OpenAD_aux_2/OpenAD_aux_3)
          OpenAD_aux_4 = (PBB%v+P%v-PB%v*2.0D00)
          OpenAD_aux_5 = (PBL%v+PBR%v-PB%v*2.0D00)
          OpenAD_lin_2 = (INT(1_w2f__i8)/HY2)
          OpenAD_lin_3 = (INT(1_w2f__i8)/HX2)
          PBLAP%v = ((OpenAD_aux_4/HY2)+(OpenAD_aux_5/HX2))
          OpenAD_aux_6 = (PBL%v+PTL%v-PL%v*2.0D00)
          OpenAD_aux_7 = (PLL%v+P%v-PL%v*2.0D00)
          OpenAD_lin_4 = (INT(1_w2f__i8)/HY2)
          OpenAD_lin_5 = (INT(1_w2f__i8)/HX2)
          PLLAP%v = ((OpenAD_aux_6/HY2)+(OpenAD_aux_7/HX2))
          OpenAD_aux_8 = (PB%v+PT%v-P%v*2.0D00)
          OpenAD_aux_9 = (PL%v+PR%v-P%v*2.0D00)
          OpenAD_lin_6 = (INT(1_w2f__i8)/HY2)
          OpenAD_lin_7 = (INT(1_w2f__i8)/HX2)
          PLAP%v = ((OpenAD_aux_8/HY2)+(OpenAD_aux_9/HX2))
          OpenAD_aux_10 = (P%v+PRR%v-PR%v*2.0D00)
          OpenAD_aux_11 = (PBR%v+PTR%v-PR%v*2.0D00)
          OpenAD_lin_8 = (INT(1_w2f__i8)/HX2)
          OpenAD_lin_9 = (INT(1_w2f__i8)/HY2)
          PRLAP%v = ((OpenAD_aux_10/HX2)+(OpenAD_aux_11/HY2))
          OpenAD_aux_12 = (P%v+PTT%v-PT%v*2.0D00)
          OpenAD_aux_13 = (PTL%v+PTR%v-PT%v*2.0D00)
          OpenAD_lin_10 = (INT(1_w2f__i8)/HY2)
          OpenAD_lin_11 = (INT(1_w2f__i8)/HX2)
          PTLAP%v = ((OpenAD_aux_12/HY2)+(OpenAD_aux_13/HX2))
          OpenAD_aux_14 = (PBLAP%v+PTLAP%v-PLAP%v*2.0D00)
          OpenAD_aux_15 = (PLLAP%v+PRLAP%v-PLAP%v*2.0D00)
          OpenAD_aux_19 = (PRLAP%v-PLLAP%v)
          OpenAD_aux_17 = (DPDY%v*OpenAD_aux_19)
          OpenAD_aux_18 = (HX*2.0D00)
          OpenAD_aux_22 = (PTLAP%v-PBLAP%v)
          OpenAD_aux_20 = (DPDX%v*OpenAD_aux_22)
          OpenAD_aux_21 = (HY*2.0D00)
          OpenAD_aux_16 = ((OpenAD_aux_17/OpenAD_aux_18)-(OpenAD_aux_20/
     +OpenAD_aux_21))
          OpenAD_lin_12 = (INT(1_w2f__i8)/HY2)
          OpenAD_lin_13 = (INT(1_w2f__i8)/HX2)
          OpenAD_lin_16 = OpenAD_aux_19
          OpenAD_lin_17 = DPDY%v
          OpenAD_lin_15 = (INT(1_w2f__i8)/OpenAD_aux_18)
          OpenAD_lin_19 = OpenAD_aux_22
          OpenAD_lin_20 = DPDX%v
          OpenAD_lin_18 = (INT(1_w2f__i8)/OpenAD_aux_21)
          OpenAD_lin_14 = R
          FVEC(INT(K))%v = ((OpenAD_aux_14/HY2)+(OpenAD_aux_15/HX2)-R*Op
     +enAD_aux_16)
          OpenAD_acc_0 = (OpenAD_lin_14*INT((-1_w2f__i8)))
          OpenAD_acc_1 = (INT((-1_w2f__i8))*OpenAD_acc_0)
          OpenAD_acc_2 = (OpenAD_lin_20*OpenAD_lin_18*OpenAD_acc_1)
          OpenAD_acc_3 = (OpenAD_lin_1*OpenAD_lin_19*OpenAD_lin_18*OpenA
     +D_acc_1)
          OpenAD_acc_4 = (OpenAD_lin_17*OpenAD_lin_15*OpenAD_acc_0)
          OpenAD_acc_5 = (OpenAD_lin_0*OpenAD_lin_16*OpenAD_lin_15*OpenA
     +D_acc_0)
          OpenAD_acc_6 = (OpenAD_lin_13+OpenAD_acc_4)
          OpenAD_acc_7 = (OpenAD_lin_13+INT((-1_w2f__i8))*OpenAD_acc_4)
          OpenAD_acc_8 = (2.0D00*INT((-1_w2f__i8))*OpenAD_lin_13+2.0D00*
     +INT((-1_w2f__i8))*OpenAD_lin_12)
          OpenAD_acc_9 = (OpenAD_lin_12+OpenAD_acc_2)
          OpenAD_acc_10 = (OpenAD_lin_12+INT((-1_w2f__i8))*OpenAD_acc_2)
          OpenAD_acc_11 = (OpenAD_lin_11*OpenAD_acc_9)
          OpenAD_acc_12 = (OpenAD_lin_10*OpenAD_acc_9)
          OpenAD_acc_13 = (OpenAD_lin_9*OpenAD_acc_6)
          OpenAD_acc_14 = (OpenAD_lin_8*OpenAD_acc_6)
          OpenAD_acc_15 = (OpenAD_lin_7*OpenAD_acc_8)
          OpenAD_acc_16 = (OpenAD_lin_6*OpenAD_acc_8)
          OpenAD_acc_17 = (OpenAD_lin_5*OpenAD_acc_7)
          OpenAD_acc_18 = (OpenAD_lin_4*OpenAD_acc_7)
          OpenAD_acc_19 = (OpenAD_lin_3*OpenAD_acc_10)
          OpenAD_acc_20 = (OpenAD_lin_2*OpenAD_acc_10)
          double_tape(double_tape_pointer) = OpenAD_acc_3
          double_tape_pointer = double_tape_pointer+1
          double_tape(double_tape_pointer) = OpenAD_acc_5
          double_tape_pointer = double_tape_pointer+1
          double_tape(double_tape_pointer) = OpenAD_acc_11
          double_tape_pointer = double_tape_pointer+1
          double_tape(double_tape_pointer) = OpenAD_acc_12
          double_tape_pointer = double_tape_pointer+1
          double_tape(double_tape_pointer) = OpenAD_acc_13
          double_tape_pointer = double_tape_pointer+1
          double_tape(double_tape_pointer) = OpenAD_acc_14
          double_tape_pointer = double_tape_pointer+1
          double_tape(double_tape_pointer) = OpenAD_acc_15
          double_tape_pointer = double_tape_pointer+1
          double_tape(double_tape_pointer) = OpenAD_acc_16
          double_tape_pointer = double_tape_pointer+1
          double_tape(double_tape_pointer) = OpenAD_acc_17
          double_tape_pointer = double_tape_pointer+1
          double_tape(double_tape_pointer) = OpenAD_acc_18
          double_tape_pointer = double_tape_pointer+1
          double_tape(double_tape_pointer) = OpenAD_acc_19
          double_tape_pointer = double_tape_pointer+1
          double_tape(double_tape_pointer) = OpenAD_acc_20
          double_tape_pointer = double_tape_pointer+1
          integer_tape(integer_tape_pointer) = K
          integer_tape_pointer = integer_tape_pointer+1
          OpenAD_Symbol_17 = (INT(OpenAD_Symbol_17)+INT(1_w2f__i8))
        END DO
        integer_tape(integer_tape_pointer) = OpenAD_Symbol_17
        integer_tape_pointer = integer_tape_pointer+1
        OpenAD_Symbol_16 = (INT(OpenAD_Symbol_16)+INT(1_w2f__i8))
      END DO
      integer_tape(integer_tape_pointer) = OpenAD_Symbol_16
      integer_tape_pointer = integer_tape_pointer+1

C taping end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.FALSE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.FALSE.
            our_rev_mode%adjoint=.TRUE.
          end if
          if (our_rev_mode%adjoint) then
C            print*, " adjoint    ", our_rev_mode
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
C adjoint
      integer_tape_pointer = integer_tape_pointer-1
      OpenAD_Symbol_0 = integer_tape(integer_tape_pointer)
      OpenAD_Symbol_1 = 1
      do while (INT(OpenAD_Symbol_1).LE.INT(OpenAD_Symbol_0))
        integer_tape_pointer = integer_tape_pointer-1
        OpenAD_Symbol_2 = integer_tape(integer_tape_pointer)
        OpenAD_Symbol_3 = 1
        do while (INT(OpenAD_Symbol_3).LE.INT(OpenAD_Symbol_2))
          integer_tape_pointer = integer_tape_pointer-1
          OpenAD_Symbol_105 = integer_tape(integer_tape_pointer)
          double_tape_pointer = double_tape_pointer-1
          OpenAD_Symbol_106 = double_tape(double_tape_pointer)
          double_tape_pointer = double_tape_pointer-1
          OpenAD_Symbol_107 = double_tape(double_tape_pointer)
          double_tape_pointer = double_tape_pointer-1
          OpenAD_Symbol_108 = double_tape(double_tape_pointer)
          double_tape_pointer = double_tape_pointer-1
          OpenAD_Symbol_109 = double_tape(double_tape_pointer)
          double_tape_pointer = double_tape_pointer-1
          OpenAD_Symbol_110 = double_tape(double_tape_pointer)
          double_tape_pointer = double_tape_pointer-1
          OpenAD_Symbol_111 = double_tape(double_tape_pointer)
          double_tape_pointer = double_tape_pointer-1
          OpenAD_Symbol_112 = double_tape(double_tape_pointer)
          double_tape_pointer = double_tape_pointer-1
          OpenAD_Symbol_113 = double_tape(double_tape_pointer)
          double_tape_pointer = double_tape_pointer-1
          OpenAD_Symbol_114 = double_tape(double_tape_pointer)
          double_tape_pointer = double_tape_pointer-1
          OpenAD_Symbol_115 = double_tape(double_tape_pointer)
          double_tape_pointer = double_tape_pointer-1
          OpenAD_Symbol_116 = double_tape(double_tape_pointer)
          double_tape_pointer = double_tape_pointer-1
          OpenAD_Symbol_117 = double_tape(double_tape_pointer)
          OpenAD_prp_2%d = OpenAD_prp_2%d+FVEC(OpenAD_Symbol_105)%d*(Ope
     +nAD_Symbol_106)
          OpenAD_prp_3%d = OpenAD_prp_3%d+FVEC(OpenAD_Symbol_105)%d*(Ope
     +nAD_Symbol_107)
          OpenAD_prp_4%d = OpenAD_prp_4%d+FVEC(OpenAD_Symbol_105)%d*(Ope
     +nAD_Symbol_108)
          OpenAD_prp_5%d = OpenAD_prp_5%d+FVEC(OpenAD_Symbol_105)%d*(Ope
     +nAD_Symbol_109)
          OpenAD_prp_6%d = OpenAD_prp_6%d+FVEC(OpenAD_Symbol_105)%d*(Ope
     +nAD_Symbol_110)
          OpenAD_prp_7%d = OpenAD_prp_7%d+FVEC(OpenAD_Symbol_105)%d*(Ope
     +nAD_Symbol_111)
          OpenAD_prp_8%d = OpenAD_prp_8%d+FVEC(OpenAD_Symbol_105)%d*(Ope
     +nAD_Symbol_112)
          OpenAD_prp_9%d = OpenAD_prp_9%d+FVEC(OpenAD_Symbol_105)%d*(Ope
     +nAD_Symbol_113)
          OpenAD_prp_10%d = OpenAD_prp_10%d+FVEC(OpenAD_Symbol_105)%d*(O
     +penAD_Symbol_114)
          OpenAD_prp_11%d = OpenAD_prp_11%d+FVEC(OpenAD_Symbol_105)%d*(O
     +penAD_Symbol_115)
          OpenAD_prp_0%d = OpenAD_prp_0%d+FVEC(OpenAD_Symbol_105)%d*(Ope
     +nAD_Symbol_116)
          OpenAD_prp_1%d = OpenAD_prp_1%d+FVEC(OpenAD_Symbol_105)%d*(Ope
     +nAD_Symbol_117)
          FVEC(OpenAD_Symbol_105)%d = 0.0d0
          PT%d = PT%d+OpenAD_prp_11%d*(-2.0D00)
          PTR%d = PTR%d+OpenAD_prp_11%d
          PTL%d = PTL%d+OpenAD_prp_11%d
          OpenAD_prp_11%d = 0.0d0
          PT%d = PT%d+OpenAD_prp_10%d*(-2.0D00)
          PTT%d = PTT%d+OpenAD_prp_10%d
          P%d = P%d+OpenAD_prp_10%d
          OpenAD_prp_10%d = 0.0d0
          PR%d = PR%d+OpenAD_prp_9%d*(-2.0D00)
          PTR%d = PTR%d+OpenAD_prp_9%d
          PBR%d = PBR%d+OpenAD_prp_9%d
          OpenAD_prp_9%d = 0.0d0
          PR%d = PR%d+OpenAD_prp_8%d*(-2.0D00)
          PRR%d = PRR%d+OpenAD_prp_8%d
          P%d = P%d+OpenAD_prp_8%d
          OpenAD_prp_8%d = 0.0d0
          P%d = P%d+OpenAD_prp_7%d*(-2.0D00)
          PR%d = PR%d+OpenAD_prp_7%d
          PL%d = PL%d+OpenAD_prp_7%d
          OpenAD_prp_7%d = 0.0d0
          P%d = P%d+OpenAD_prp_6%d*(-2.0D00)
          PT%d = PT%d+OpenAD_prp_6%d
          PB%d = PB%d+OpenAD_prp_6%d
          OpenAD_prp_6%d = 0.0d0
          PL%d = PL%d+OpenAD_prp_5%d*(-2.0D00)
          P%d = P%d+OpenAD_prp_5%d
          PLL%d = PLL%d+OpenAD_prp_5%d
          OpenAD_prp_5%d = 0.0d0
          PL%d = PL%d+OpenAD_prp_4%d*(-2.0D00)
          PTL%d = PTL%d+OpenAD_prp_4%d
          PBL%d = PBL%d+OpenAD_prp_4%d
          OpenAD_prp_4%d = 0.0d0
          PB%d = PB%d+OpenAD_prp_3%d*(-2.0D00)
          PBR%d = PBR%d+OpenAD_prp_3%d
          PBL%d = PBL%d+OpenAD_prp_3%d
          OpenAD_prp_3%d = 0.0d0
          PB%d = PB%d+OpenAD_prp_2%d*(-2.0D00)
          P%d = P%d+OpenAD_prp_2%d
          PBB%d = PBB%d+OpenAD_prp_2%d
          OpenAD_prp_2%d = 0.0d0
          PL%d = PL%d-OpenAD_prp_1%d
          PR%d = PR%d+OpenAD_prp_1%d
          OpenAD_prp_1%d = 0.0d0
          PB%d = PB%d-OpenAD_prp_0%d
          PT%d = PT%d+OpenAD_prp_0%d
          OpenAD_prp_0%d = 0.0d0
          integer_tape_pointer = integer_tape_pointer-1
          OpenAD_Symbol_4 = integer_tape(integer_tape_pointer)
          IF (OpenAD_Symbol_4.ne.0) THEN
            PTR%d = 0.0d0
          ELSE
            integer_tape_pointer = integer_tape_pointer-1
            OpenAD_Symbol_118 = integer_tape(integer_tape_pointer)
            X(OpenAD_Symbol_118)%d = X(OpenAD_Symbol_118)%d+PTR%d
            PTR%d = 0.0d0
          ENDIF
          integer_tape_pointer = integer_tape_pointer-1
          OpenAD_Symbol_5 = integer_tape(integer_tape_pointer)
          IF (OpenAD_Symbol_5.ne.0) THEN
            integer_tape_pointer = integer_tape_pointer-1
            OpenAD_Symbol_104 = integer_tape(integer_tape_pointer)
            X(OpenAD_Symbol_104)%d = X(OpenAD_Symbol_104)%d+PT%d
            PT%d = 0.0d0
            PTT%d = 0.0d0
          ELSE
            integer_tape_pointer = integer_tape_pointer-1
            OpenAD_Symbol_6 = integer_tape(integer_tape_pointer)
            IF (OpenAD_Symbol_6.ne.0) THEN
              integer_tape_pointer = integer_tape_pointer-1
              OpenAD_Symbol_119 = integer_tape(integer_tape_pointer)
              X(OpenAD_Symbol_119)%d = X(OpenAD_Symbol_119)%d+PTT%d
              PTT%d = 0.0d0
              PT%d = 0.0d0
            ELSE
              integer_tape_pointer = integer_tape_pointer-1
              OpenAD_Symbol_120 = integer_tape(integer_tape_pointer)
              X(OpenAD_Symbol_120)%d = X(OpenAD_Symbol_120)%d+PTT%d
              PTT%d = 0.0d0
              integer_tape_pointer = integer_tape_pointer-1
              OpenAD_Symbol_121 = integer_tape(integer_tape_pointer)
              X(OpenAD_Symbol_121)%d = X(OpenAD_Symbol_121)%d+PT%d
              PT%d = 0.0d0
            ENDIF
          ENDIF
          integer_tape_pointer = integer_tape_pointer-1
          OpenAD_Symbol_7 = integer_tape(integer_tape_pointer)
          IF (OpenAD_Symbol_7.ne.0) THEN
            PTL%d = 0.0d0
          ELSE
            integer_tape_pointer = integer_tape_pointer-1
            OpenAD_Symbol_122 = integer_tape(integer_tape_pointer)
            X(OpenAD_Symbol_122)%d = X(OpenAD_Symbol_122)%d+PTL%d
            PTL%d = 0.0d0
          ENDIF
          integer_tape_pointer = integer_tape_pointer-1
          OpenAD_Symbol_8 = integer_tape(integer_tape_pointer)
          IF (OpenAD_Symbol_8.ne.0) THEN
            integer_tape_pointer = integer_tape_pointer-1
            OpenAD_Symbol_103 = integer_tape(integer_tape_pointer)
            X(OpenAD_Symbol_103)%d = X(OpenAD_Symbol_103)%d+PR%d
            PR%d = 0.0d0
            PRR%d = 0.0d0
          ELSE
            integer_tape_pointer = integer_tape_pointer-1
            OpenAD_Symbol_9 = integer_tape(integer_tape_pointer)
            IF (OpenAD_Symbol_9.ne.0) THEN
              integer_tape_pointer = integer_tape_pointer-1
              OpenAD_Symbol_123 = integer_tape(integer_tape_pointer)
              X(OpenAD_Symbol_123)%d = X(OpenAD_Symbol_123)%d+PRR%d
              PRR%d = 0.0d0
              PR%d = 0.0d0
            ELSE
              integer_tape_pointer = integer_tape_pointer-1
              OpenAD_Symbol_124 = integer_tape(integer_tape_pointer)
              X(OpenAD_Symbol_124)%d = X(OpenAD_Symbol_124)%d+PRR%d
              PRR%d = 0.0d0
              integer_tape_pointer = integer_tape_pointer-1
              OpenAD_Symbol_125 = integer_tape(integer_tape_pointer)
              X(OpenAD_Symbol_125)%d = X(OpenAD_Symbol_125)%d+PR%d
              PR%d = 0.0d0
            ENDIF
          ENDIF
          integer_tape_pointer = integer_tape_pointer-1
          OpenAD_Symbol_102 = integer_tape(integer_tape_pointer)
          X(OpenAD_Symbol_102)%d = X(OpenAD_Symbol_102)%d+P%d
          P%d = 0.0d0
          integer_tape_pointer = integer_tape_pointer-1
          OpenAD_Symbol_10 = integer_tape(integer_tape_pointer)
          IF (OpenAD_Symbol_10.ne.0) THEN
            integer_tape_pointer = integer_tape_pointer-1
            OpenAD_Symbol_101 = integer_tape(integer_tape_pointer)
            X(OpenAD_Symbol_101)%d = X(OpenAD_Symbol_101)%d+PLL%d
            PLL%d = 0.0d0
            PL%d = 0.0d0
          ELSE
            integer_tape_pointer = integer_tape_pointer-1
            OpenAD_Symbol_11 = integer_tape(integer_tape_pointer)
            IF (OpenAD_Symbol_11.ne.0) THEN
              integer_tape_pointer = integer_tape_pointer-1
              OpenAD_Symbol_126 = integer_tape(integer_tape_pointer)
              X(OpenAD_Symbol_126)%d = X(OpenAD_Symbol_126)%d+PL%d
              PL%d = 0.0d0
              PLL%d = 0.0d0
            ELSE
              integer_tape_pointer = integer_tape_pointer-1
              OpenAD_Symbol_127 = integer_tape(integer_tape_pointer)
              X(OpenAD_Symbol_127)%d = X(OpenAD_Symbol_127)%d+PLL%d
              PLL%d = 0.0d0
              integer_tape_pointer = integer_tape_pointer-1
              OpenAD_Symbol_128 = integer_tape(integer_tape_pointer)
              X(OpenAD_Symbol_128)%d = X(OpenAD_Symbol_128)%d+PL%d
              PL%d = 0.0d0
            ENDIF
          ENDIF
          integer_tape_pointer = integer_tape_pointer-1
          OpenAD_Symbol_12 = integer_tape(integer_tape_pointer)
          IF (OpenAD_Symbol_12.ne.0) THEN
            PBR%d = 0.0d0
          ELSE
            integer_tape_pointer = integer_tape_pointer-1
            OpenAD_Symbol_129 = integer_tape(integer_tape_pointer)
            X(OpenAD_Symbol_129)%d = X(OpenAD_Symbol_129)%d+PBR%d
            PBR%d = 0.0d0
          ENDIF
          integer_tape_pointer = integer_tape_pointer-1
          OpenAD_Symbol_13 = integer_tape(integer_tape_pointer)
          IF (OpenAD_Symbol_13.ne.0) THEN
            integer_tape_pointer = integer_tape_pointer-1
            OpenAD_Symbol_100 = integer_tape(integer_tape_pointer)
            X(OpenAD_Symbol_100)%d = X(OpenAD_Symbol_100)%d+PBB%d
            PBB%d = 0.0d0
            PB%d = 0.0d0
          ELSE
            integer_tape_pointer = integer_tape_pointer-1
            OpenAD_Symbol_14 = integer_tape(integer_tape_pointer)
            IF (OpenAD_Symbol_14.ne.0) THEN
              integer_tape_pointer = integer_tape_pointer-1
              OpenAD_Symbol_130 = integer_tape(integer_tape_pointer)
              X(OpenAD_Symbol_130)%d = X(OpenAD_Symbol_130)%d+PB%d
              PB%d = 0.0d0
              PBB%d = 0.0d0
            ELSE
              integer_tape_pointer = integer_tape_pointer-1
              OpenAD_Symbol_131 = integer_tape(integer_tape_pointer)
              X(OpenAD_Symbol_131)%d = X(OpenAD_Symbol_131)%d+PBB%d
              PBB%d = 0.0d0
              integer_tape_pointer = integer_tape_pointer-1
              OpenAD_Symbol_132 = integer_tape(integer_tape_pointer)
              X(OpenAD_Symbol_132)%d = X(OpenAD_Symbol_132)%d+PB%d
              PB%d = 0.0d0
            ENDIF
          ENDIF
          integer_tape_pointer = integer_tape_pointer-1
          OpenAD_Symbol_15 = integer_tape(integer_tape_pointer)
          IF (OpenAD_Symbol_15.ne.0) THEN
            PBL%d = 0.0d0
          ELSE
            integer_tape_pointer = integer_tape_pointer-1
            OpenAD_Symbol_133 = integer_tape(integer_tape_pointer)
            X(OpenAD_Symbol_133)%d = X(OpenAD_Symbol_133)%d+PBL%d
            PBL%d = 0.0d0
          ENDIF
          OpenAD_Symbol_3 = INT(OpenAD_Symbol_3)+1
        END DO
        OpenAD_Symbol_1 = INT(OpenAD_Symbol_1)+1
      END DO

C adjoint end
            our_rev_mode%arg_store=.FALSE.
            our_rev_mode%arg_restore=.TRUE.
            our_rev_mode%plain=.FALSE.
            our_rev_mode%tape=.TRUE.
            our_rev_mode%adjoint=.FALSE.
          end if
        end subroutine head
